﻿using System.Collections.Generic;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.GameObjects.Primitives;
using Transformable_Engine_v2.Engine.Graphics;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace AngryManagementMayhem.Controller.Map
{
    public class BaseScreen : Container
    {
        public Dictionary<int, CollisionDefinition> MapData { get; private set; }
        public float DepthLevel { get; private set; }

        public BaseScreen(float depthLevel = 1)
        {
            DepthLevel = depthLevel;
            MapData = new Dictionary<int, CollisionDefinition>();

            AddChildren(new RectanglePrimitive {
                                                   Shape = new TE_Rectangle(0, 0, 44, 30),
                                                   OutlineColor = Color.Red,
                                                   FillColor = Color.White.ToTransparentColor(),
                                                   OutlineThickness = 2,
                                               });
        }

        protected void AddMapCell(int positionX, int positionY, CollisionDefinition collisionDefinition)
        {
            collisionDefinition.Position = Position.Offset(positionX*CollisionDefinition.CollisionSize,
                                                  positionY*CollisionDefinition.CollisionSize);
            MapData.Add(ScreenLocationToIndex(positionX, positionY), collisionDefinition);
        }

        public static int ScreenLocationToIndex(int indexX, int indexY)
        {
            return indexX + indexY*1000;
        }
    }
}